package com.ranjiaqi.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @ClassName TestStream02
 * @Description TODO
 * @Author hp
 * @Date 2021/7/6 10:26
 * @Version 1.0
 **/
public class TestStream02 {
    public static void main(String[] args) {
        List<String> one = new ArrayList<>();
        one.add("迪丽热巴");
        one.add("宋远桥");
        one.add("苏星河");
        one.add("老子");
        one.add("庄子");
        one.add("孙子");
        one.add("洪七公");

        List<String> two = new ArrayList<>();
        two.add("古力娜扎");
        two.add("张无忌");
        two.add("张三丰");
        two.add("赵丽颖");
        two.add("张二狗");
        two.add("张天爱");
        two.add("张三");

        one.forEach(System.out::println);

        List<String> collect = one.stream().filter(s -> s.length() == 3)
                .limit(3).collect(Collectors.toList());
        List<String> collect1 = two.stream().filter(s -> s.startsWith("张"))
                .skip(2).collect(Collectors.toList());

        Stream<String> concat = Stream.concat(collect.stream(), collect1.stream());
        concat.forEach(System.out::println);
    }


}
